package com.qf.service.impl;

import com.qf.service.AuthService;
import org.springframework.http.HttpCookie;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;

/**
 * @author YDW
 * projectName:project2202_4
 * time:2022/7/6 17:48
 * description:
 */
@Service
public class AuthServiceImpl implements AuthService {
    @Override
    public String findJwtTokenFromCookie(ServerHttpRequest request, String cookieName) {
        MultiValueMap<String, HttpCookie> cookies = request.getCookies();

        if (cookies == null) {
            return null;
        }

        //获取cookie中的jwttoken
        HttpCookie cookie = cookies.getFirst(cookieName);
        //如果不为null，则返回cookie值
        if (cookie != null) {
            return cookie.getValue();
        }


        return null;
    }
}
